define(function(require, exports){
	var $ = require("jquery");
	var pubjs = require('pubjs');
	var view = require('@base/view');
	var util = require('util');
	var Edit = require('@mod/fieldEdit').base;
	var dspUtil = require('dspUtil');

	exports.base = Edit.extend({
		init:function(config){
			config = pubjs.conf(config, {
				fields: [
					{text: LANG('数据库名称'), type: 'input', field: 'db', validate: true}
					,{text: LANG('分页'), tip: LANG('第几页, 默认 1'), type: 'input', field: 'page'}
					,{text: LANG('分页大小'), tip: LANG('每页大小，不要大于20，不好展示哦, 默认 10'), type: 'input', field: 'size'}
					,{text: LANG('查询条件'), tip: LANG('JSON的查询格式,$sort 属性表示是排序'), type: 'textarea', field: 'query', style:"width: 500px; height: 100px"}
					,{text: LANG('返回字段'), tip: LANG('以逗豆隔开'), type: 'input', field: 'fields', style:"width: 500px"}
					,{text: LANG('查询'), type: 'button', field: 'go', config: {
						'value': LANG('确定'),
						'class': 'btn btn-primary'
					}}
				],
				isPop: true,
				Title: LANG('数据信息:')
			});

			this.$id = null;
			this.Super('init', arguments);
		}
		,dataChange: function(field, v) {
			this.Super('dataChange', arguments);
			if(field === 'go')
			{
				var data = this.getData();
				if(this.validate(data))
				{
					delete data._id;
					delete data.go;
					var url = 'api/admin/blackMagic?type=db' + dspUtil.queryString(data);
					window.open(url);
				}
			}
		}
	});
});